/**
 * 系统部门
 */
import { IsDefined, IsInt, IsNotEmpty, IsString, Length } from "class-validator";
import { BaseEntity, DefaultValue } from "../BaseEntity";
import { TStatus } from "../../types/CommonType";
import { Model } from "sequelize";

export default class SysDeptEntity extends BaseEntity {
  id?: number;

  @DefaultValue(null)
  parentId: number;

  @Length(2, 20)
  @IsString()
  @IsNotEmpty()
  @IsDefined()
  public deptName: string;

  @IsString()
  public ancestors: string;

  @IsInt()
  public orderNum: string;

  @IsString()
  public leader: string;

  @IsString()
  public phone: string;

  @IsString()
  public email: string;

  @IsString()
  @IsNotEmpty()
  @IsDefined()
  public status: TStatus;

  public static transform(plainObject: object): SysDeptEntity {
    return super.baseTransform(SysDeptEntity, plainObject);
  }
}

export interface ISysDeptModel extends Model<SysDeptEntity> {}
